<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<title>结算</title>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
	<style type="text/css" >
		.nav-font-c{
			color: #007bff;
		}
	</style>
</head>
<body>
<div class="container-fluid " style="height: 42px;background: #8bcc93">
  	<div class="container pt-2" style="color: #fff">
  		<div class="float-left" style="font-size: 12px;"> 				
  				<span class="un-login-user-name" style="font-size:13px;cursor:pointer;" >亲 ~~ 您好</span>
  				
  				<span class="login-userSpan" style="font-size:12px;cursor:pointer;" > 您好 : &nbsp; 
			 		<span class="login-user-name" style="font-size: 14px;color: #0062cc;cursor:pointer;"> </span>   
				</span>			
  		</div>
		<div class="float-right">  
			<div class="fl-r-unlogin" >
			<span class="user-help" style="font-size: 13px;color: #0062cc;cursor:pointer;">帮助</span>
				<span id="user-longin" class="ml-3" style="font-size: 13px;color: #0062cc;cursor:pointer;" >登录</span>
				<span id="user-register" style="font-size: 13px;color: #0062cc;cursor:pointer;"  class="ml-3">注册</span>
			</div>
			<div class="fl-r-login" style="display: none;" >
			<span class="user-help" style="font-size: 13px;color: #0062cc;cursor:pointer;">帮助</span>
				<span id="user-relongin" style="font-size: 12px;color: #0062cc;cursor:pointer;" class="ml-3" >重新登录</span>
			</div>
		</div>

		<div class="float-none"></div>	
	</div>
</div>

<div class="container mt-2" >
	<ul class="nav nav-font-c nav-tabs" id="myTab" role="tablist">
	  <li class="nav-item index-html">
	    <a class="nav-link "  data-toggle="tab"  role="tab"  >首页</a>
	  </li>
	  <li class="nav-item nav-font-c search-order-html">
	    <a class="nav-link " data-toggle="tab" role="tab" >订单查询</a>
	  </li>
	  <li class="nav-item  settlement-html">
	    <a class="nav-link active"  data-toggle="tab"  role="tab"  >结算</a>
	  </li>
	</ul>

	<div class="mt-3">
		<span style="font-size: 14px;color: #666">预收入</span><br />
		<span style="color: #888;font-size: 12px;">订单预返利：
			<span class="willGetMoneyUser" style="color: red;font-size: 16px;"> </span> 元
		</span><br />
		<span style="color: #888;font-size: 12px;">邀请码预收入：
			<span class="willGetMoneyCode" style="color: red;font-size: 16px;"> </span>  元
		</span><br /><br />
		<span style="font-size: 14px;color: #666">已经结算</span><br />
		<span style="color:  #666;font-size: 12px;">订单返利：
			<span class="nowGetMoneyUser" style="color: red;font-size: 16px;"> </span> 元
		</span><br />
		<span style="color:  #666;font-size: 12px;">邀请码收入：
			<span class="nowGetMoneyCode" style="color: red;font-size: 16px;"> </span> 元
		</span><br />

		<hr />
		<span style="color: #333;font-size: 13px;">可提取：
			<span class="nowGetMoney" style="color: red;font-size: 18px;"> </span>  元
		</span><br /><br />
		<span style="color: red;font-size: 14px;">提现前先到点击用户名填写您的支付宝账号哟</span><br /><br />
		<button type="button" class="btn btn-primary btn-block b-user-tx">点击全部提取</button>


	</div>

	<div class="mt-3">
		<span style="color: #888;font-size: 12px;">本次提取正在处理中：
			<span class="last-tq" style="color: red;font-size: 16px;"></span>
		</span><br />
		<span style="color: #888;font-size: 12px;">
					上次成功提取：
			<span class="lastSuccess-tq" style="color: red;font-size: 16px;"></span>
		</span><br /><br />

		<span style="color: #00d943;font-size: 12px;">1到2天会转账到您的支付宝账号里面</span>

	</div>
</div>

<!-- jQuery first, then Tether, then Bootstrap JS.  B-->

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
 
<!-- jQuery first, then Tether, then Bootstrap JS. E -->

<script>
var nowGetMoney = 0;

function initData(){
	$.ajax({
		   type: "POST",
		   url: "/mytk/tklSettlement/userSettlement",
		   dataType:"json",
		   success: function(msg){
		   
			   	console.info(msg)
		
			   	if(msg.code == 200){
					$('.willGetMoneyUser').text(msg.body.willGetMoneyUser);
					$('.willGetMoneyCode').text(msg.body.willGetMoneyCode);

					$('.nowGetMoneyUser').text(msg.body.nowGetMoneyUser);
					$('.nowGetMoneyCode').text(msg.body.nowGetMoneyCode);

					$('.nowGetMoney').text(msg.body.nowGetMoney);

					nowGetMoney = msg.body.nowGetMoney;
					if(msg.body.lastSettlement){
						$('.last-tq').text(msg.body.lastSettlement.money +"元");
					}else{
						$('.last-tq').text("无记录");
					}

					if(msg.body.lastSuccess){
						$('.lastSuccess-tq').text(msg.body.lastSuccess.money +"元");
					}else{
						$('.lastSuccess-tq').text("无记录");
					}

			   	}else{
			   		//alert(msg.msg);
			   	
			   	}
			   	
		   },
		   error: function(XMLHttpRequest, textStatus, errorThrown) {
	
				alert("请求失败！请联系管理员");
		   }
		})
}

initData();

(function(){

	function usertx(){

		if(nowGetMoney ==0){

			alert("请至少大于0元才可以提现");
			return false;
		}
		$.ajax({
		   type: "POST",
		   url: "/mytk/tklSettlement/settlement",
		   dataType:"json",
		   success: function(msg){

			   	console.info(msg)

			   	if(msg.code == 200){

			   		if(msg.body == 1){
			   			alert('提现申请成功！1到3天内转账到您支付宝内');
			   		}else if(msg.body == -2){
			   			alert('你还有申请没有处理，着急提现可联系管理员！');
			   		}


			   	}else{
			   		alert(msg.msg);


			   	}

		   },
		   error: function(XMLHttpRequest, textStatus, errorThrown) {
	
				alert("请求失败！请联系管理员");
		   }
		})

	}

	$(".b-user-tx").off().on("click", usertx);
	$(".user-help").off().on("click", function(){

			window.location.href='use-help.html';
	});

	$(".index-html").off().on("click", function(){
		
		window.location.href='index.html';
	});
	$(".search-order-html").off().on("click", function(){
			
			window.location.href='search-order.html';
	});

	$("#user-longin").off().on("click", function(){
			
			window.location.href='longin-register.html';
	});
	$("#user-relongin").off().on("click", function(){
			
			window.location.href='longin-register.html';
	});
	$("#user-register").off().on("click", function(){
			
			window.location.href='longin-register.html?regPar=reg';
	});
	$(".settlement-html").off().on("click", function(){
			
			window.location.href='settlement.html';
	});

	$(".login-user-name").off().on("click", function(){

			window.location.href='user-info.html';
	});

}())
function init (){
	$.ajax({
		   type: "POST",
		   url: "/mytk/tklUser/webToken",
		   dataType:"json",
		   success: function(msg){

			   	console.info(msg)

			   	if(msg.code == 200){

			   		$('.un-login-user-name').hide();
			   		$('.login-user-name').text(msg.body.name);

			   		$('.login-userSpan').show();

			   		$('.fl-r-unlogin').hide();
			   		$('.fl-r-login').show();

			   	}else{
			   		//alert(msg.msg);
			   		window.location.href='index.html';

			   	}

		   },
		   error: function(XMLHttpRequest, textStatus, errorThrown) {

				alert("请求失败！请联系管理员");
		   }
		})

}

init();
</script>
</body>
</html>